import { BaseModel } from '@/common/base/base.model';
import { BeforeInsert, BeforeUpdate, Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { EvaluationModel } from "@/module/evaluation/evaluation.model";
import { SpecificationModel } from "@/module/specification/specification.model";

@Entity('EVALUATION_SPECIFICATION', {
  synchronize: false,
}) // 评测规格
export class EvaluationSpecificationModel extends BaseModel {
  @Column({
    comment: '评测uuid',
    type: 'uuid',
  })
  evaluationUuid: string;
  @ManyToOne(() => EvaluationModel, {
    createForeignKeyConstraints: false
  })
  @JoinColumn({
    name: 'evaluation_uuid',
    referencedColumnName: 'uuid',
  })
  evaluation: EvaluationModel;

  @Column({
    comment: '规格uuid',
    type: 'uuid',
  })
  specificationUuid: string;
  @ManyToOne(() => SpecificationModel, {
    createForeignKeyConstraints: false
  })
  @JoinColumn({
    name: 'specification_uuid',
    referencedColumnName: 'uuid',
  })
  specification: SpecificationModel;

  @Column({
    comment: '值',
    type: 'varchar',
    length: 500,
  })
  value: string;

  @Column({
    comment: '数字值',
    type: 'decimal',
    nullable: true,
  })
  numberValue: number | null;

  @Column({
    comment: '排序',
    type: 'int2',
  })
  sort: number;
}
